﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Directory的简单练习
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //string path = @"D:\\test\\config";

            ////static DirectoryInfo CreateDirectory(string path)
            ////在指定路径创建所有的目录和子目录，除非它们已经存在
            ////Directory.CreateDirectory(path);

            ////static bool Exist(string path)
            ////确认指定路径的目录是否存在
            //Console.WriteLine(Directory.Exists(path));

            ////static string GetCurrentDirectory()
            ////获取应用程序的当前工作目录
            //Console.WriteLine(Directory.GetCurrentDirectory());

            ////static IEnumberable<string> EnumerateDirectories(string path)
            ////返回指定路径目录中的所有子目录完整名称，返回迭代类型
            //IEnumerable<string> files = Directory.EnumerateDirectories(path);
            //IEnumerator<string> enumerator = files.GetEnumerator();
            //foreach (string file in files)
            //{
            //    Console.WriteLine(file);
            //}
            //while (enumerator.MoveNext())
            //{
            //    Console.WriteLine(enumerator.Current);
            //}

            ////static IEnumberable<string> GetDirectories(string path)
            ////返回指定路径目录中的所有子目录完整名称，返回字符串类型
            //string[] directorys = Directory.GetDirectories(path);
            //foreach(string directory in directorys)
            //{
            //    Console.WriteLine(directory);
            //}

            ////static IEnumerable<string> EnumerateFiles(string path)
            ////返回指定路径目录中的所有文件的路径和名称，返回迭代类型
            //IEnumerable<string> files1 = Directory.EnumerateFiles(path);
            //IEnumerator<string> enumerator1 = files.GetEnumerator();
            //foreach (string file in files1)
            //{
            //    Console.WriteLine(file);
            //}
            //while (enumerator1.MoveNext())
            //{
            //    Console.WriteLine(enumerator.Current);
            //}

            ////static string[] GetFiles(string path)
            ////返回指定路径目录中的所有文件路径和名称，返回字符串数组
            //string[] files2 = Directory.GetFiles(path);
            //foreach (string file in files2)
            //{
            //    Console.WriteLine(file);
            //}

            ////static void Delete(string path)
            ////删除指定的目录，并删除该目录中的所有子目录（目录中不能有文件）
            ////Directory.Delete(path);

            ////static void Delete(string path)
            ////删除指定的目录，并删除该目录中的所有子目录
            ////如果recurvise 为 false 则目录中不能有文件
            ////如果为true 则目录和里面的文件一起删除
            ////Directory.Delete(path, true);

            //string path = @"D:\day11\demo\test";
            //if (!Directory.Exists(path))
            //{
            //    Directory.CreateDirectory(path);
            //}
            string path = @"D:\day11\demo\test\study.txt";
            //if (!File.Exists(path))
            //{
            //    File.Create(path);
            //}

            File.WriteAllLines(path, new string[] { "姓名：光头强", "年龄：32", "地址：北京市，昌平区，光头村" });
            File.Copy(path, @"D:\day11\demo\test\study-copy.txt");

        }
    }
}